<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div>
      <el-card class="box-card">
          <el-breadcrumb separator-class="el-icon-arrow-right">
              <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
              <el-breadcrumb-item>用户管理</el-breadcrumb-item>
              <el-breadcrumb-item>权限列表</el-breadcrumb-item>
          </el-breadcrumb>
          <el-row :gutter="20">
              <el-col :span="12">
                  <el-input placeholder="请输入内容" v-model="search">
                      <el-button slot="append" icon="el-icon-search" ></el-button>
                  </el-input>
              </el-col>
              <el-col :span="6">
              </el-col>
          </el-row>
          <el-table :data="permList" border style="width: 100%">
              <el-table-column type="index"  label="序号" > </el-table-column>
              <el-table-column prop="name" label="名" > </el-table-column>
              <el-table-column prop="codename" label="codename" > </el-table-column>
              <el-table-column prop="content_type.app_label" label="应用"></el-table-column>
              <el-table-column prop="content_type.model" label="模型"></el-table-column>
          </el-table>
          <el-pagination
             @current-change="handleCurrentChange"
             :current-page="pagination.page"
             :page-size="pagination.size"
             layout="total, prev, pager, next, jumper"
             :total="pagination.total">
          </el-pagination>
      </el-card>
      <!-- 修改对话框 -->
      <!-- <el-dialog
           title="修改用户"
           :visible.sync="editUserdialogVisible" @close="resetForm('editUser')">
           <el-form :model="editUserForm" :rules="editUserRules" ref="editUser" label-width="100px" >
             <el-form-item label="用户名" >
               {{editUserForm.username}}
             </el-form-item>
             <el-form-item label="电子邮箱" prop="email">
               <el-input v-model="editUserForm.email"></el-input>
             </el-form-item>
             <el-form-item label="电话号码" prop="phone">
               <el-input v-model="editUserForm.phone"></el-input>
             </el-form-item>
           </el-form>
            <span slot="footer" class="dialog-footer">
            <el-button @click="editUserdialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="editUser">确 定</el-button>
           </span>
      </el-dialog> -->
      <!-- 添加窗口 -->
  </div>
</template>

<script>
export default {
  created() {
    this.getList()
  },
  data() {
    return {
      search: '',
      addPermdialogVisible: false,
      addPermForm: {

      },
      addPermRules: {
      },
      permList: [
      ],
      pagination: {
        total: 0,
        size: 20,
        page: 1
      }
    }
  },
  methods: {
    resetForm(name) {
      // const name = 'addPerm'
      // console.log('++++++++++++++++++++')
      console.log(name)
      this.$refs[name].resetFields()
    },
    async getList(page = 1) {
      if (!page) {
        page = 1
      }
      // all permissions /perms 返回所有权限
      const { data: response } = await this.$http.get('users/perms/', {
        params: {
          page,
          search: this.search
        }
      })
      if (response.code) {
        return this.$message.error(response.message)
      }
      this.permList = response.results
      this.pagination = response.pagination
    },
    handleCurrentChange(page) {
      this.getList(page)
    }
  }
}
</script>

<style>

</style>